const appState = {
    isMenuOpen: false,
    mobileModel: false,
    admin_nickname: '',
    userInfo: JSON.parse(localStorage.getItem('userInfo')),
    popUp: true,
    defaultPagination: {
        current: 1,
        pageSize: 10,
        defaultPageSize: 10,
        showQuickJumper: true,
        showSizeChanger: true,
        pageSizeOptions: [10, 20, 30, 40, 50],
        showTotal : (total, range) => {
            return `共 ${total} 条数据 显示${range[0]} 到 ${range[1]}`;
        },
    }
};

const appReducer = (state = appState, action) => {
    if (action.type === 'setAppState') {
        return {
            ...state,
            ...action.state,
        };
    } else {
        return state;
    }
};

const commonReducer = (state = {}, action) => {
    if (action.type === 'setState') {
        return {
            ...state,
            ...action.state,
        };
    } else {
        return state;
    }
};

export default {
    appReducer,
    commonReducer
};
